const Router = require('koa-router');
const router = new Router();
const {db, QueryTypes} = require("../../models/db");


router.post('/deliver/getArc', async ctx => {
    let tenantId = ctx.user.tenantId;
    let admins = await db.query(`select a.id,a.name,b.name roleName from admin a left join role b on a.roleId=b.id where a.tenantId=${tenantId} and a.isDel=0`, {type: QueryTypes.SELECT});
    let cars = await db.models['cars'].findAll({
        where: {
            tenantId,
            isDel: 0
        },
        attributes:['id', ['licence', 'name']]
    })
    let ret = {
        cars: cars,
        admins: admins
    }
    return ctx.suc('', ret);
})


module.exports = router;
